<template v-loading="loading">
	<el-card shadow="never" style="--el-card-padding: 0px;cursor: pointer;border-radius: 7px;" @click="clickToDocument()">
	   <sc-statistic :title="item.title||'加载中'" :value="(item.Count||0)"
				   :valueclass="item.valueclass"
					   :bgclass="item.bgclass"
					   :bgimg="item.bgimg"
					   groupSeparator>
	   </sc-statistic>
   </el-card>

</template>

<script>
import scStatistic from '@/components/scStatisticIndex';
import globalparam from "@/constant/model/globalparam";
import tool from "@/utils/tool";

export default {
name: 'assetStatistic',
components: {
   scStatistic
},
data() {
   return {
	   item: {
		   title:"变动中",
		   Count:0,
		   bgclass:"bg5",
		   bgimg:"bgimg5",
		   valueclass:"value5"
	   },
	   loading : false,
	   //管理部门范围
	   manageDeptIds:tool.current.manageDeptIds(),
	   //单据统计范围
	   documentSummaryStatistics: '',
	   //单据未完成时状态范围
	   statusList: [],
	   documentConfigIds: [],
	   loginUsers: this.$TOOL.current.user(),
   }
},
created() {
},
async mounted() {
   this.$cache.data.loadGlobalParam(globalparam.documentSummaryStatistics.paramCode).then((res) => {
	   this.documentSummaryStatistics = res;
	   this.$cache.data.loadGlobalParam(globalparam.documentSummaryState.paramCode).then((resp) => {
		   this.statusList = resp;
		   this.$API.asset.documentConfig.listData.post({type:'change'}).then((rsp =>{
			   if(rsp.code === 2000){
				   rsp.data.forEach((item)=>{
					   this.documentConfigIds.push(item.id)
				   })
				   this.loadData();
			   }
		   }))
	   })
   })
},
methods: {
   loadData() {
	   let queryParams = {};
	   this.loading = true;
	   this.fomateQueryParams(queryParams, this);
	   this.$API.asset.document.selectCountByQuery.post(queryParams).then((rsp =>{
		   if(rsp.code === 2000){
			   this.item.Count = rsp.data;
		   }
		   this.loading = false;
	   }))
   },
   fomateQueryParams(queryParams,_this) {
	   queryParams.documentSummaryStatistics = _this.documentSummaryStatistics;
	   queryParams.manageDeptIds = _this.manageDeptIds;
	   queryParams.statusList = _this.statusList;
	   queryParams.queryDocumentConfigIds = _this.documentConfigIds;
   },
   clickToDocument(){
	   let queryParams = {};
	   this.fomateQueryParams(queryParams, this);
	   this.searchAsset(queryParams)
   },
   searchAsset(queryParams) {
	   let title = "变动中";
	   //跳转到搜索台账页面
	   let fromRouteId = this.$TOOL.crypto.MD5(this.$route.path);//当前页面的路由地址
	   let key = this.$TOOL.crypto.MD5(title);//可以做为key的关键字段或内容
	   /**
		*  1 = 根据管理部门，根据登录账户管理范围，资产的管理部门在账户管理范围内的显示<br>
		*  2 = 根据使用部门，根据登录账户管理范围，资产的使用部门在账户管理范围内的显示<br>
		*  3 = 根据管理部门或使用部门，根据登录账户管理范围，资产的使用部门或管理部门在账户管理范围内的显示<br>
		*  其它 = 根据管理部门，按台账，根据使用部门或管理部门或借用部门在管理范围内的
		*/
		   //设置搜索参数
	   let routeParams = {
			   id: key,
			   title: title,
			   fixedParams:{
				   manageDeptIds:queryParams.manageDeptIds,
				   statusList:queryParams.statusList
			   },//固定搜索参数，打开页面后，用户通过搜索界面的清空按钮无法清除
			   searchParams: queryParams
		   };
	   this.$store.dispatch("addRouteParams", routeParams);
	   this.$router.push({
		   name: "toDocumentList",
		   params: {fromRouteId: fromRouteId, key: key}
	   });
   },
   }
}
</script>

<style scoped>
.el-card {
margin-bottom: 0px;
padding: 0px;

}
.el-card__body {
padding: 0px !important;
}


</style>
